home *** CD-ROM | disk | FTP | other *** search
- /*
- CInternetConfig.cpp
-
- C++ Class Interface for Internet Config. Basically this class encapsulates the
- IC Switch Glue.c code, putting a C++ class wrapper around IC.
-
- This class still requires the inclusion of the IC Link In.c, IC Link In Subs.c, and
- IC Call Glue.c C source files into your project.
- */
-
- #include <AppleTalk.h>
- #include <Aliases.h>
- #include <Errors.h>
-
- // include types and key information
- #include "IC Types.h"
- #include "IC Keys.h"
-
- // include the main header for this file
- #include "CInternetConfig.hpp"
-
- // include the headers for the component and resource routines
- #include "IC Component API.h"
- #include "IC Resource API.h"
-
- CInternetConfig::CInternetConfig(OSType theCreator){
- ICError err;
- ICRRecordPtr instr;
-
- instr=(ICRRecordPtr)NewPtr(sizeof(ICRRecord));
- err=MemError();
-
- if (err==noErr){
- err=ICCStart(&(instr->instance),theCreator);
- if (err!=noErr)
- err=ICRStart(instr,theCreator);
-
- if (err!=noErr){
- DisposePtr((Ptr)instr);
- theInstance=(ICInstance)0;
- } else {
- theInstance=(ICInstance)instr;
- }
- }
- lastError=err;
- }
-
- CInternetConfig::~CInternetConfig(void){
- ICError err;
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
-
- if (theInstance!=(ICInstance)0){
- if (rp->instance!=(ComponentInstance)0){
- err=ICCStop(rp->instance);
- } else {
- err=ICRStop(rp);
- }
-
- DisposePtr((Ptr)rp);
- }
- }
-
- OSErr CInternetConfig::GetComponentInstance(Ptr* cip){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- *cip=(Ptr)rp->instance;
-
- if (*cip==(Ptr)0)
- err=badComponentInstance;
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::GetLastError(void){
- return (OSErr)lastError;
- }
-
- OSErr CInternetConfig::MapICError(ICError err){
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::FindConfigFile(short count,ICDirSpecArrayPtr folders){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCFindConfigFile(rp->instance,count,folders);
- else
- err=ICRFindConfigFile(rp,count,folders);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::FindUserConfigFile(ICDirSpec* where){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCFindUserConfigFile(rp->instance,where);
- else
- err=ICRFindUserConfigFile(rp,where);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::GeneralFindConfigFile(Boolean search_prefs,Boolean can_create,
- short count,ICDirSpecArrayPtr folders){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCGeneralFindConfigFile(rp->instance,search_prefs,can_create,count,folders);
- else
- err=ICRGeneralFindConfigFile(rp,search_prefs,can_create,count,folders);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::ChooseConfig(void){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCChooseConfig(rp->instance);
- else
- err=ICRChooseConfig(rp);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::ChooseNewConfig(void){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCChooseNewConfig(rp->instance);
- else
- err=ICRChooseNewConfig(rp);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::GetConfigName(StringPtr name,Boolean longname){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCGetConfigName(rp->instance,longname,name);
- else
- err=ICRGetConfigName(rp,longname,name);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::GetConfigReference(ICConfigRefHandle ref){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCGetConfigReference(rp->instance,ref);
- else
- err=ICRGetConfigReference(rp,ref);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::SetConfigReference(ICConfigRefHandle ref,long flags){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCSetConfigReference(rp->instance,ref,flags);
- else
- err=ICRSetConfigReference(rp,ref,flags);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::SpecifyConfigFile(FSSpecPtr config){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCSpecifyConfigFile(rp->instance,config);
- else
- err=ICRSpecifyConfigFile(rp,config);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::GetSeed(long* seed){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCGetSeed(rp->instance,seed);
- else
- err=ICRGetSeed(rp,seed);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::GetPerm(ICPerm* perm){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCGetPerm(rp->instance,perm);
- else
- err=ICRGetPerm(rp,perm);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::DefaultFileName(StringPtr name){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCDefaultFileName(rp->instance,name);
- else
- err=ICRDefaultFileName(rp,name);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::Begin(ICPerm perm){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCBegin(rp->instance,perm);
- else
- err=ICRBegin(rp,perm);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::GetPref(const StringPtr key,ICAttr* attr,Ptr buf,long* size){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCGetPref(rp->instance,key,attr,buf,size);
- else
- err=ICRGetPref(rp,key,attr,buf,size);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::SetPref(const StringPtr key,ICAttr attr,Ptr buf,long size){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCSetPref(rp->instance,key,attr,buf,size);
- else
- err=ICRSetPref(rp,key,attr,buf,size);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::FindPrefHandle(const StringPtr key,ICAttr* attr,Handle prefh){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCFindPrefHandle(rp->instance,key,attr,prefh);
- else
- err=ICRFindPrefHandle(rp,key,attr,prefh);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::GetPrefHandle(const StringPtr key,ICAttr* attr,Handle* prefh){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCGetPrefHandle(rp->instance,key,attr,prefh);
- else
- err=ICRGetPrefHandle(rp,key,attr,prefh);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::SetPrefHandle(const StringPtr key,ICAttr attr,Handle prefh){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCSetPrefHandle(rp->instance,key,attr,prefh);
- else
- err=ICRSetPrefHandle(rp,key,attr,prefh);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::CountPref(long* count){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCCountPref(rp->instance,count);
- else
- err=ICRCountPref(rp,count);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::GetIndPref(long n,StringPtr key){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCGetIndPref(rp->instance,n,key);
- else
- err=ICRGetIndPref(rp,n,key);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::DeletePref(const StringPtr key){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCDeletePref(rp->instance,key);
- else
- err=ICRDeletePref(rp,key);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::End(void){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCEnd(rp->instance);
- else
- err=ICREnd(rp);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::EditPreferences(const StringPtr key){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCEditPreferences(rp->instance,key);
- else
- err=ICREditPreferences(rp,key);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::ParseURL(StringPtr hint,Ptr data,long len,long* selStart,long* selEnd,Handle url){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCParseURL(rp->instance,hint,data,len,selStart,selEnd,url);
- else
- err=ICRParseURL(rp,hint,data,len,selStart,selEnd,url);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::LaunchURL(StringPtr hint,Ptr data,long len,long* selStart,long* selEnd){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCLaunchURL(rp->instance,hint,data,len,selStart,selEnd);
- else
- err=ICRLaunchURL(rp,hint,data,len,selStart,selEnd);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::MapFilename(StringPtr filename,ICMapEntry* entry){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCMapFilename(rp->instance,filename,entry);
- else
- err=ICRMapFilename(rp,filename,entry);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::MapTypeCreator(OSType fType,OSType fCreator,StringPtr filename,ICMapEntry* entry){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCMapTypeCreator(rp->instance,fType,fCreator,filename,entry);
- else
- err=ICRMapTypeCreator(rp,fType,fCreator,filename,entry);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::MapEntriesFilename(Handle entries,StringPtr filename,ICMapEntry* entry){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCMapEntriesFilename(rp->instance,entries,filename,entry);
- else
- err=ICRMapEntriesFilename(rp,entries,filename,entry);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::MapEntriesTypeCreator(Handle entries,OSType fType,OSType fCreator,StringPtr filename,ICMapEntry* entry){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCMapEntriesTypeCreator(rp->instance,entries,fType,fCreator,filename,entry);
- else
- err=ICRMapEntriesTypeCreator(rp,entries,fType,fCreator,filename,entry);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::CountMapEntries(Handle entries,long* count){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCCountMapEntries(rp->instance,entries,count);
- else
- err=ICRCountMapEntries(rp,entries,count);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::GetIndMapEntry(Handle entries,long ndx,long* pos,ICMapEntry* entry){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCGetIndMapEntry(rp->instance,entries,ndx,pos,entry);
- else
- err=ICRGetIndMapEntry(rp,entries,ndx,pos,entry);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::GetMapEntry(Handle entries,long pos,ICMapEntry* entry){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCGetMapEntry(rp->instance,entries,pos,entry);
- else
- err=ICRGetMapEntry(rp,entries,pos,entry);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::SetMapEntry(Handle entries,long pos,ICMapEntry* entry){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCSetMapEntry(rp->instance,entries,pos,entry);
- else
- err=ICRSetMapEntry(rp,entries,pos,entry);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::DeleteMapEntry(Handle entries,long pos){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCDeleteMapEntry(rp->instance,entries,pos);
- else
- err=ICRDeleteMapEntry(rp,entries,pos);
-
- lastError=err;
- return (OSErr)err;
- }
-
- OSErr CInternetConfig::AddMapEntry(Handle entries,ICMapEntry* entry){
- ICRRecordPtr rp=(ICRRecordPtr)theInstance;
- ICError err=(ICError)paramErr;
-
- if (theInstance==(ICInstance)0)
- return paramErr;
-
- if (rp->instance!=(ComponentInstance)0)
- err=ICCAddMapEntry(rp->instance,entries,entry);
- else
- err=ICRAddMapEntry(rp,entries,entry);
-
- lastError=err;
- return (OSErr)err;
- }
-